using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;


/// Released under MS-PL (Microsoft permissive license):  http://www.microsoft.com/resources/sharedsource/licensingbasics/permissivelicense.mspx 
/// Copyright (c) Microsoft Corporation.  All rights reserved.
namespace NLarge
{
    public class NotifyIconHolder
    {
        internal System.Windows.Forms.NotifyIcon NI;

        internal ToolStripMenuItem tsmiAbout = new ToolStripMenuItem("&Options");
        ToolStripSeparator tsi1 = new ToolStripSeparator();
        internal ToolStripMenuItem tsmiZoom = new ToolStripMenuItem("&Zoom");
        internal ToolStripMenuItem tsmiDraw = new ToolStripMenuItem("&Draw");
        internal ToolStripMenuItem tsmiCountdown = new ToolStripMenuItem("&Break Timer");
        ToolStripSeparator tsi2 = new ToolStripSeparator();
        internal ToolStripMenuItem tsmiExit = new ToolStripMenuItem("E&xit");

        private Window1 MainWindowRef;

        public NotifyIconHolder(Window1 mainWindow)
        {
            MainWindowRef = mainWindow;

            NI = new System.Windows.Forms.NotifyIcon();
            NI.Text = "NLarge";
            NI.Icon = ResourceIcon.NLarge;
            NI.Visible = true;

            System.Windows.Forms.ContextMenuStrip cms = new System.Windows.Forms.ContextMenuStrip();
            NI.ContextMenuStrip = cms;

            cms.Items.Add(tsmiAbout);
            cms.Items.Add(tsi1);
            cms.Items.Add(tsmiZoom);
            cms.Items.Add(tsmiDraw);
            cms.Items.Add(tsmiCountdown);
            cms.Items.Add(tsi2);
            cms.Items.Add(tsmiExit);


            NI.DoubleClick += delegate { NI.ContextMenuStrip.Show(Cursor.Position.X, Cursor.Position.Y); };

            tsmiAbout.Click += new EventHandler(tsmiAbout_Click);
            tsmiZoom.Click += delegate { if (!MainWindowRef.ZoomActive) MainWindowRef.BeginNewZoomIn(true); };
            tsmiDraw.Click += delegate { if (!MainWindowRef.ZoomActive) MainWindowRef.BeginNewZoomIn(false); };
            tsmiCountdown.Click += delegate { if (!MainWindowRef.ZoomActive) MainWindowRef.BeginCountdown(); };
            tsmiExit.Click += delegate
            {
                MainWindowRef.Close(); NI.Visible = false; AboutNLarge.KillAboutDialog();
            };
        }

        void tsmiAbout_Click(object sender, EventArgs e)
        {
            AboutNLarge.PresentAboutDialog();
        }
        

    }
}
